import request from '@/utils/request.js'

/**
 * 登录接口
 *
 * @method register 注册
 * @method getInfo 获取用户信息
 * @method logout 退出登录
 * @method getCaptcha 获取验证码
 * @method login 注册
 */
export function useLoginApi() {
  return {
    register(data) {
      return request({
        url: '/auth/register',
        method: 'post',
        data: data
      })
    },
    getInfo() {
      return request({
        url: '/auth/info',
        method: 'get'
      })
    },
    logout() {
      return request({
        url: '/auth/logout',
        method: 'post'
      })
    },
    getCaptcha(randomStr) {
      return request({
        url: '/auth/captcha',
        method: 'get',
        params: {
          randomStr
        }
      })
    },
    login(data) {
      return request({
        url: '/auth/login',
        method: 'post',
        data: data
      })
    }
  }
}
